Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay unfolding #928

Merged
merged 4 commits into from
Dec 6, 2024
Merged

Delay unfolding #928

merged 4 commits into from
Dec 6, 2024

Conversation

nilehmann
Copy link
Member

@nilehmann nilehmann commented Dec 5, 2024

Delay unfolding of definitions until after refinement type checking (and before fixpoint encoding). I tested this in vtock and veriasm, and I didn't notice any changes in performance.

There's one change in behavior. The following code

#![allow(unused)]
#![flux::defs {
    fn inc1(x: int) -> int {
        x + 1
    }
}]

#[flux::sig(fn() -> i32[inc1(0)])]
fn moo() -> i32 {
    2
}

previously produced

error[E0999]: refinement type error
  --> attic/playground.rs:10:5
   |
10 |     2
   |     ^ a postcondition cannot be proved
-Ztrack-diagnostics: created at crates/flux-refineck/src/lib.rs:202:10
   |
note: this is the condition that cannot be proved
  --> attic/playground.rs:4:9
   |
4  |         x + 1
   |         ^^^^^
note: inside this call
  --> attic/playground.rs:8:25
   |
8  | #[flux::sig(fn() -> i32[inc1(0)])]
   |                         ^^^^^^^

but now it produces

error[E0999]: refinement type error
  --> attic/playground.rs:10:5
   |
10 |     2
   |     ^ a postcondition cannot be proved
-Ztrack-diagnostics: created at crates/flux-refineck/src/lib.rs:202:10
   |
note: this is the condition that cannot be proved
  --> attic/playground.rs:8:25
   |
8  | #[flux::sig(fn() -> i32[inc1(0)])]
   |                         ^^^^^^^

This is because previously we first unfolded inc1(0) into 0 + 1 and then generated a head 2 = 0 + 1 assigning the span of 0 + 1 to the entire head. With this change, we first generate 2 = inc1(0) assigning it the span of inc1(0). We later unfold it to 2 = 0 + 1 but the span of the entire head doesn't change. We could recover the behavior by having a different type of head for equalities and adjusting spans accordingly after unfolding. However, I don't think this is objectively worse, I found the old behavior a bit confusing.

@nilehmann nilehmann force-pushed the nico/delay-unfolding branch from 62bdfdc to e9908a5 Compare December 6, 2024 17:11
@nilehmann nilehmann marked this pull request as ready for review December 6, 2024 17:13
@nilehmann nilehmann merged commit bf34120 into main Dec 6, 2024
7 checks passed
@nilehmann nilehmann deleted the nico/delay-unfolding branch December 6, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant